//
// Copyright (c) 2009-2011, chunquedong
//
// This file is part of ChunMap project
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
//
// History:
//   2011-09-04  Jed Young  Creation
//

using chunmapModel
using chunmapData
using gfx2
using gfx
using gfx2Imp
using web
using chunmapView
using chunmapRaster

**
** GetMap
**
class GetMap
{
  const Envelope envelope
  LayerList layers
  const Size size
  const MimeType format

  new make(|This| f) { f(this) }

  Void reponse(WebRes res)
  {
    image := getImage
    res.headers["Content-Type"] = format.toStr
    image.save(res.out, format)
  }

  Image2 getImage()
  {
    Gfx2.setEngine("AWT")

    map := CMap(size)
    map.layers = layers
    map.view.setViewEnvelope(envelope)
    //map.fullView
    map.render

    return map.image
  }
}